home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / BuildingBlocks / Comparable.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  2.6 KB  |  114 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Comparable.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef    __COMPARABLE__
  15. #define    __COMPARABLE__
  16.  
  17. #ifndef    __TYPES__
  18. #include "Types.h"
  19. #endif
  20.  
  21. #ifndef    __DIRECTOBJECT__
  22. #include "DirectObject.h"
  23. #endif
  24.  
  25. #pragma push
  26. #pragma segment Comparable
  27.  
  28. class ostream;
  29.  
  30. /***********************************|****************************************/
  31.  
  32. class AComparable : public TDirectObject
  33. {
  34. public:
  35.  
  36.     virtual    ~AComparable ();
  37.  
  38.     virtual    long                    Compare ( const AComparable& ) const;
  39.     virtual    ostream&                operator >> ( ostream& ) const;
  40.  
  41.     // don’t overide these
  42.  
  43.             Boolean                    operator < ( const AComparable& ) const;
  44.             Boolean                    operator <= ( const AComparable& ) const;
  45.             Boolean                    operator == ( const AComparable& ) const;
  46.             Boolean                    operator != ( const AComparable& ) const;
  47.             Boolean                    operator >= ( const AComparable& ) const;
  48.             Boolean                    operator > ( const AComparable& ) const;
  49.  
  50. protected:    AComparable ();
  51. };
  52.  
  53. /***********************************|****************************************/
  54. /***********************************|****************************************/
  55.  
  56. inline long
  57. AComparable::Compare ( const AComparable& that ) const
  58. {
  59.     return (long) this - (long) &that;
  60. }
  61.  
  62. /***********************************|****************************************/
  63.  
  64. inline Boolean
  65. AComparable::operator < ( const AComparable& that ) const
  66. {
  67.     return Compare ( that ) < 0;
  68. }
  69.  
  70. /***********************************|****************************************/
  71.  
  72. inline Boolean
  73. AComparable::operator <= ( const AComparable& that ) const
  74. {
  75.     return Compare ( that ) <= 0;
  76. }
  77.  
  78. /***********************************|****************************************/
  79.  
  80. inline Boolean
  81. AComparable::operator == ( const AComparable& that ) const
  82. {
  83.     return Compare ( that ) == 0;
  84. }
  85.  
  86. /***********************************|****************************************/
  87.  
  88. inline Boolean
  89. AComparable::operator != ( const AComparable& that ) const
  90. {
  91.     return Compare ( that ) != 0;
  92. }
  93.  
  94. /***********************************|****************************************/
  95.  
  96. inline Boolean
  97. AComparable::operator >= ( const AComparable& that ) const
  98. {
  99.     return Compare ( that ) >= 0;
  100. }
  101.  
  102. /***********************************|****************************************/
  103.  
  104. inline Boolean
  105. AComparable::operator > ( const AComparable& that ) const
  106. {
  107.     return Compare ( that ) > 0;
  108. }
  109.  
  110. #pragma pop
  111.  
  112. /***********************************|****************************************/
  113.  
  114. #endif    // __COMPARABLE__